/*
 * 文件描述：
 * 总线设备驱动模型
 * 设备相关（引脚）
 * 分配/设置/注册一个platform_device
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/uaccess.h>

static struct resource led_resource[] = {
 [0] = {
     .start = 0x56000050,
     .end = 0x56000050 + 8 -1,
     .flags = IORESOURCE_MEM,
 },
 [1] = {
     .start = 5,
     .end = 5,
     .flags = IORESOURCE_IRQ,
 }
};

static void led_release(struct device *dev)
{

}

struct platform_device led_dev = {
    .name = "myled",
    .id = -1,
    .num_resources = ARRAY_SIZE(led_resource),
    .resource = led_resource,
    .dev = {
        .release = led_release,
    },
};

int leds_init(void)
{
    //注册平台设备
    platform_device_register(&led_dev);
    return 0;
}

void leds_exit(void)
{
    //卸载平台设备
    platform_device_unregister(&led_dev);
}

module_init(leds_init); //添加入口函数
module_exit(leds_exit); //删除入口函数

MODULE_LICENSE("GPL");
